home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2.sit / Raven 1.2 / Source / Foundation / OS / ZInterruptTimer.h < prev    next >
Text File  |  1997-04-13  |  3KB  |  136 lines

  1. /*
  2.  *  File:       ZInterruptTimer.h
  3.  *  Summary:       Interrupt driven timer classes
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996-1997 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <2>     4/13/97    JDJ        MTimeMgrTimer descends from MExitAction instead of
  12.  *                                    using an ExitToShell patch.
  13.  *         <1>     6/23/96    JDJ        Created
  14.  */
  15.  
  16. #pragma once
  17.  
  18. #include <Retrace.h>
  19. #include <Timer.h>
  20.  
  21. #include <ZBaseTimer.h>
  22. #include <ZExitAction.h>
  23.  
  24.  
  25. // ===================================================================================
  26. //    class MVBLTimer
  27. // ===================================================================================
  28. class MVBLTimer : public MBaseTimer {
  29.  
  30.     typedef MBaseTimer Inherited;
  31.  
  32. //-----------------------------------
  33. //    Initialization/Destruction
  34. //
  35. public:
  36.     virtual                   ~MVBLTimer();
  37.                         
  38.     explicit            MVBLTimer(MilliSecond freq, bool running = false);
  39.                         // Frequency is the interval at which the timer wants to be called.
  40.                     
  41. //-----------------------------------
  42. //    Inherited API
  43. //
  44. public:
  45.     virtual void        StopTimer();
  46.                         
  47.     virtual void        StartTimer();
  48.     
  49.     virtual    void        SetTimerFreq(MilliSecond freq);
  50.  
  51. //-----------------------------------
  52. //    Internal API
  53. //
  54. protected:
  55.             void         InstallTimer();
  56.             
  57.             void         RemoveTimer();
  58.  
  59.     static pascal void     OnInterrupt(VBLTaskPtr taskPtr);
  60.  
  61. //-----------------------------------
  62. //    Data members
  63. //
  64. protected:
  65.      struct SVBLRecord {        
  66.         VBLTask        task;
  67.         long        myA5;
  68.         MVBLTimer*    thisPtr;
  69.         short        vblFreq;        
  70.         bool        inTask;
  71.      };
  72.  
  73.      SVBLRecord    mVBLInfo;                // Data accessed from within the VBL task.
  74.     bool        mTimerInstalled;
  75. };
  76.  
  77.  
  78. // ===================================================================================
  79. //    class MTimeMgrTimer
  80. // ===================================================================================
  81. class MTimeMgrTimer : public MBaseTimer, public MExitAction {
  82.  
  83.     typedef MBaseTimer Inherited;
  84.  
  85. //-----------------------------------
  86. //    Initialization/Destruction
  87. //
  88. public:
  89.     virtual                   ~MTimeMgrTimer();
  90.                         
  91.     explicit            MTimeMgrTimer(MilliSecond freq, bool running = false);
  92.                         // Frequency is the interval at which the timer wants to be called.
  93.                     
  94. //-----------------------------------
  95. //    MBaseTimer API
  96. //
  97. public:
  98.     virtual void        StopTimer();
  99.                         
  100.     virtual void        StartTimer();
  101.     
  102.     virtual    void        SetTimerFreq(MilliSecond freq);
  103.  
  104. //-----------------------------------
  105. //    MExitAction API
  106. //
  107. protected:
  108.     virtual void         OnAbnormalExit();
  109.  
  110. //-----------------------------------
  111. //    Internal API
  112. //
  113. protected:
  114.             void         InstallTimer();
  115.             
  116.             void         RemoveTimer();
  117.  
  118.     static pascal void     OnInterrupt(TMTask* taskPtr);
  119.  
  120. //-----------------------------------
  121. //    Data members
  122. //
  123. protected:
  124.      struct STimeMgrRecord {        
  125.         TMTask            task;
  126.         long            mMyA5;
  127.         MTimeMgrTimer*    thisPtr;
  128.         bool            inTask;
  129.      };
  130.  
  131.     STimeMgrRecord    mTimeMgrInfo;                // Data accessed from within the time manager task.        
  132.      bool            mTimerInstalled;
  133. };
  134.  
  135.  
  136.